import { Connection } from 'mongoose';
import { getInstance } from '../../db';
import { accountSchema } from '../../schemas/accountSchema';

interface IRegister {
  uid?: string;
  username?: string;
  password?: string;
  phoneNumber?: string;
  [props: string]: any;
}

export async function registerService(params: IRegister):Promise<IAnyObject> {
  const db: Connection = await getInstance();

  const accountmodel = db.model('accountmodel', accountSchema);

  const result = await accountmodel.create(params);

  return result;
}
